import { combineReducers } from 'redux'

const moduleFn = require.context('./modules', false, /\.js$/i)
const modules = moduleFn.keys().reduce((prev, curr) => {
  const key = curr.match(/\.\/(\w+)\.js$/i)[1]
  const value = moduleFn(curr).default
  prev[key] = value
  return prev
}, {})

const reducer = combineReducers(modules)

export default reducer
